package uranium.combo;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;

import javax.swing.ComboBoxModel;
import javax.swing.JComboBox;
import uranium.db.DBManager;
import uranium.db.DBStateChange;

public class MyComboProd extends JComboBox implements DBStateChange{
	private DBManager dbm = null;
	public void stateChange()
	{
		this.removeAllItems();
		String s="SELECT cbarre,descrizione FROM cancelleria";
		ResultSet rs=dbm.executeQuery(s);
		try
		{
			while(rs.next())
			{
				Object o3 = rs.getObject("cbarre");
				Object o1=rs.getObject("descrizione");
				Object o=new String(o3+" "+o1);
				this.addItem(o);
			}
		} catch (SQLException e)
		{
			
			e.printStackTrace();
		}
	}

	/**
	 * 
	 */
	public MyComboProd(DBManager dbm){
		super();
		this.dbm = dbm;
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param aModel
	 */
	public MyComboProd(ComboBoxModel aModel)
	{
		super(aModel);
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param items
	 */
	public MyComboProd(Object[] items)
	{
		super(items);
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param items
	 */
	public MyComboProd(Vector<?> items)
	{
		super(items);
		// TODO Auto-generated constructor stub
	}

}
